package com.design.designmode.action.iter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hxl
 * @since 2023-04-18
 */
public class BookAggregate implements Aggregate {
    private List<Book> list = new ArrayList<Book>();

    public void add(Book book) {
        list.add(book);
    }

    public Book get(int index) {
        return list.get(index);
    }

    public int getSize() {
        return list.size();
    }


    @Override
    public CustomIterator CreateIterator() {
        //!!!!!!!!!!!!!!!!!!!!!!!! 需要把 Aggregate 放入 iterator
        return new BookIterator(this);
    }
}
